package com.yuncheng.oaApi.controller;

import java.util.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yuncheng.oaApi.service.INkDgzzgslbService;
import com.yuncheng.vo.HttpResult;

import com.yuncheng.annotation.AutoLog;
import com.yuncheng.utils.I18nUtil;
import com.yuncheng.common.base.controller.BaseController;
import com.yuncheng.oaApi.entity.NkDgzzgslb;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.yuncheng.system.api.SystemAPI;
import org.springframework.context.annotation.Lazy;

/**
 * @Description: 内控-对公转账公司列表
 * @Author: gs
 * @Date: 2024-05-23
 * @Version: V1.0
 */
@Api(tags = "内控-对公转账公司列表接口")
@RestController
@RequestMapping("/api/spzx-oa/nkDgzzgslb")
public class NkDgzzgslbController extends BaseController<NkDgzzgslb, INkDgzzgslbService> {

    private static final Logger log = LoggerFactory.getLogger(NkDgzzgslbController.class);

    @Resource
    private INkDgzzgslbService nkDgzzgslbService;

    @Resource
    @Lazy
    private SystemAPI systemAPI;

    /**
     * 分页列表查询
     *
     * @param nkDgzzgslb
     * @param pageNo
     * @param pageSize
     * @param
     * @return
     */
    @AutoLog(value = "内控-对公转账公司列表-分页列表查询")
    @ApiOperation(value = "内控-对公转账公司列表-分页列表查询")
    @GetMapping(value = "/list")
    public HttpResult<?> queryPageList(NkDgzzgslb nkDgzzgslb, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        LambdaQueryWrapper<NkDgzzgslb> queryWrapper = new LambdaQueryWrapper<>();
        Page<NkDgzzgslb> page = new Page<>(pageNo, pageSize);
        IPage<NkDgzzgslb> pageList = nkDgzzgslbService.page(page, queryWrapper);

        return HttpResult.ok(pageList);
    }



    /**
     * 添加
     *
     * @param nkDgzzgslb
     * @return
     */
    @AutoLog(value = "内控-对公转账公司列表-添加")
    @ApiOperation(value = "内控-对公转账公司列表-添加")

    @PostMapping(value = "/add")
    public HttpResult<?> add(@RequestBody NkDgzzgslb nkDgzzgslb) {
        HttpResult<String> result = new HttpResult(true);
        nkDgzzgslbService.save(nkDgzzgslb);
        result.setResult(nkDgzzgslb.getId());
        result.setMessage(I18nUtil.message("save.success"));
        return result;
    }

    /**
     * 编辑
     *
     * @param nkDgzzgslb
     * @return
     */
    @AutoLog(value = "内控-对公转账公司列表-编辑")
    @ApiOperation(value = "内控-对公转账公司列表-编辑")
    //@RequiresPermissions("gs:NkDgzzgslb:edit")
    @PutMapping(value = "/edit")
    public HttpResult<?> edit(@RequestBody NkDgzzgslb nkDgzzgslb) {
        nkDgzzgslbService.updateById(nkDgzzgslb);
        return HttpResult.ok(I18nUtil.message("update.success"));
    }

    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "内控-对公转账公司列表-通过id删除")
    @ApiOperation(value = "内控-对公转账公司列表-通过id删除")
    //@RequiresPermissions("gs:NkDgzzgslb:delete")
    @DeleteMapping(value = "/delete")
    public HttpResult<?> delete(@RequestParam("id") String id) {
        nkDgzzgslbService.removeById(id);
        return HttpResult.ok(I18nUtil.message("delete.success"));
    }

    /**
     * 通过id批量删除
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "内控-对公转账公司列表-批量删除")
    @ApiOperation(value = "内控-对公转账公司列表-批量删除")
    //@RequiresPermissions("gs:NkDgzzgslb:delete")
    @DeleteMapping(value = "/deleteBatch")
    public HttpResult<?> deleteBatch(@RequestParam("ids") String ids) {
        nkDgzzgslbService.removeByIds(Arrays.asList(ids.split(",")));
        return HttpResult.ok(I18nUtil.message("delete.success"));
    }

    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    @AutoLog(value = "内控-对公转账公司列表-通过id查询")
    @ApiOperation(value = "内控-对公转账公司列表-通过id查询")
    @GetMapping(value = "/queryById")
    public HttpResult<?> queryById(@RequestParam("id") String id) {
        NkDgzzgslb nkDgzzgslb = nkDgzzgslbService.getById(id);
        return HttpResult.ok(nkDgzzgslb);
    }

    /**
     * 导出excel
     */
    @AutoLog(value = "内控-对公转账公司列表-导出excel")
    @ApiOperation(value = "内控-对公转账公司列表-导出excel")
    //@RequiresPermissions("gs:NkDgzzgslb:export")
    @RequestMapping(value = "/exportExcel")
    public ModelAndView exportExcel(HttpServletRequest request,  NkDgzzgslb nkDgzzgslb) {
    	return super.exportExcel(request, nkDgzzgslb, NkDgzzgslb.class, "内控-对公转账公司列表");
    }

    /**
     * excel导入数据
     */
    @AutoLog(value = "内控-对公转账公司列表-excel导入数据")
    @ApiOperation(value = "内控-对公转账公司列表-excel导入数据")
    //@RequiresPermissions("gs:NkDgzzgslb:import")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public HttpResult<?> importExcel(HttpServletRequest request) {
    		return super.importExcel(request, NkDgzzgslb.class);
    }

}
